[Storehouse] 003 - Payloadless ledger#8574
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| pathFinderVersion uint8 | ||
| } | ||
|
|
||
| var _ ledger.Ledger = (*Ledger)(nil) |
There was a problem hiding this comment.
Added an interface check here, but I didn't define ledger.PayloadlessLedger interface for payloadless ledger struct yet, will add in future PR.
| // register at the given state. The returned slice is in the same order as | ||
| // `query.Keys()`. | ||
| // | ||
| // HasPaths replaces the full ledger's ValueSizes for payloadless mode, since |
There was a problem hiding this comment.
HasPaths replaces full ledger's ValueSizes method
| // | ||
| // GetSingleLeafHash replaces the full ledger's GetSingleValue for payloadless | ||
| // mode, since payload values are not retained. | ||
| func (l *PayloadlessLedger) GetSingleLeafHash(query *ledger.QuerySingleValue) (*hash.Hash, error) { |
There was a problem hiding this comment.
GetSingleLeafHash replaces the full ledger's GetSingleValue
| // | ||
| // GetLeafHashes replaces the full ledger's Get for payloadless mode, since | ||
| // payload values are not retained. | ||
| func (l *PayloadlessLedger) GetLeafHashes(query *ledger.Query) ([]*hash.Hash, error) { |
There was a problem hiding this comment.
GetLeafHashes replaces the full ledger's Get
| return nil, fmt.Errorf("could not get proofs: %w", err) | ||
| } | ||
|
|
||
| return batchProof, nil |
There was a problem hiding this comment.
The full ledger's Prove returns ledger.Proof which is a []byte slice, which is encoded trie.
However, we return a structured data *ledger.PayloadlessTrieBatchProof for now instead of []byte, because the caller will need to assemble with the payload value, and also read the leaf hash to verify the payload value. In the future, it can be optimized to []byte to reduce some decoding work.
d790588 to
de9df7f
Compare
| } | ||
|
|
||
| // Trie returns the trie stored in the forest with the given root hash. | ||
| func (l *PayloadlessLedger) Trie(rootHash ledger.RootHash) (*payloadless.MTrie, error) { |
There was a problem hiding this comment.
Is this missing an error doc. I think this can return "no trie is stored in the forest". Same for MostRecentTouchedState.
| } | ||
|
|
||
| // StateByIndex returns the state at the given index. `-1` returns the last index. | ||
| func (l *PayloadlessLedger) StateByIndex(index int) (ledger.State, error) { |
There was a problem hiding this comment.
nit: The doc string is missing the expected errors.
b10a8f7 to
ba46fa2
Compare
6334c77 to
939e60e
Compare
ba46fa2 to
830e903
Compare
05f95c3 to
939e60e
Compare
939e60e to
d113e4c
Compare
Create Payloadless ledger that mirrors
complete.Ledgerfromledger/complete/ledger.goSee Spec